package com.wushijia.designpatterns.adapter;

/**
 * description:适配器模式测试
 * @author yang
 * @date 2018/1/17 21:13
 */
public class AdapterTest {

  public static void main(String[] args) {
    Duck duck = new MallardDuck();
    WildTurkey wildTurkey = new WildTurkey();
    Duck duckTurekey = new TurkeyAdapter(wildTurkey);

    System.out.println("火鸡说：");
    wildTurkey.gobble();
    wildTurkey.fly();

    System.out.println("鸭子说：");
    testAdapter(duck);

    System.out.println("披着鸭子外衣的火鸡说：");
    testAdapter(duckTurekey);
  }

  static void testAdapter(Duck duck) {
    duck.quack();
    duck.fly();
  }

}
